package org.spa.modules.demo.controller;

import org.spa.common.api.vo.Result;
import org.spa.common.aspect.annotation.AutoLog;
import org.spa.modules.demo.entity.TestTabel;
import org.spa.modules.demo.service.TestTabelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 描述: 
 * author: P0081447
 * date: 2022-03-27 15:32:13
 */
@Api(tags="")
@RestController
@RequestMapping(value="/sys/testTabel")
public class TestTabelController {

    @Autowired
	private TestTabelService testTabelService;
     
    /**
	 * 添加
	 *
	 * @param testTabel
	 * @return
	 */
	@AutoLog(value = "-添加")
	@ApiOperation(value="-添加", notes="-添加")
	@PostMapping(value = "/add")
	public Result<?> add(@RequestBody TestTabel testTabel) {
		return testTabelService.insert(testTabel);
	}
	
	/**
	 * 编辑
	 *
	 * @param testTabel
	 * @return
	 */
	@AutoLog(value = "-编辑")
	@ApiOperation(value="-编辑", notes="-编辑")
	@PutMapping(value = "/edit")
	public Result<?> edit(@RequestBody TestTabel testTabel) {
		return testTabelService.updateById(testTabel);
		// return Result.OK("编辑成功!");
	}
	
	/**
	 * 通过id删除
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "-通过id删除")
	@ApiOperation(value="-通过id删除", notes="-通过id删除")
	@DeleteMapping(value = "/delete")
	public Result<?> delete(@RequestParam(name="id",required=true) int id) {
		return testTabelService.deleteById(id);
		// return Result.OK("删除成功!");
	}
	
	/**
	 * 通过id查询
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "-通过id查询")
	@ApiOperation(value="-通过id查询", notes="-通过id查询")
	@GetMapping(value = "/queryById")
	public Result<?> queryById(@RequestParam(name="id",required=true) int id) {
		return testTabelService.selectById(id);
		//return Result.OK(testTabel);
	}
}
